package com.bytedance.frameworks.baselib.network.http.c.a.a;

import com.bytedance.retrofit2.mime.TypedByteArray;
import com.bytedance.retrofit2.Converter;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonWriter;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;

final class b implements Converter {
    private static final Charset a;
    private final TypeAdapter b;

    static {
        a = Charset.forName("UTF-8");
    }

    b(TypeAdapter arg1) {
        this.b = arg1;
    }

    public final Object convert(Object value) throws IOException {
        ByteArrayOutputStream v0 = new ByteArrayOutputStream(1024);
        JsonWriter writer = new com.google.gson.Gson().newJsonWriter(new OutputStreamWriter(v0, a));
        this.b.write(writer, value);
        writer.close();
        return new TypedByteArray("application/json; charset=UTF-8", v0.toByteArray());
    }
}

